﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using POSSystem.DAL;
using System.Collections.Specialized;
using System.Data.SqlClient;
using System.Data;

namespace POSSystem.BLL
{
    public class View_Contracts : _View_Contracts
    {
        public static View_Contracts GetAllContract()
        {
            try
            {
                View_Contracts contracts = new View_Contracts();
                contracts.Where.BranchID.Value = Branches.CurrentBranchID;
                contracts.Query.Load();

                return contracts;
            }
            catch (Exception ex)
            {
                ErrorLog.WriteToFile("", "", ex.StackTrace);
                throw ex;
            }
        }

        public static View_Contracts GetNewContract()
        {
            try
            {
                View_Contracts contracts = new View_Contracts();
                ListDictionary parameters = new ListDictionary();
                parameters.Add(new SqlParameter("@branchID", SqlDbType.Int, 0), Branches.CurrentBranchID);

                contracts.LoadFromSql("LoadNewContracts", parameters);

                return contracts;
            }
            catch (Exception ex)
            {
                ErrorLog.WriteToFile("", "", ex.StackTrace);
                throw ex;
            }
        }

        public static View_Contracts GetPaidContract()
        {
            try
            {
                View_Contracts contracts = new View_Contracts();
                ListDictionary parameters = new ListDictionary();
                parameters.Add(new SqlParameter("@branchID", SqlDbType.Int, 0), Branches.CurrentBranchID);
                contracts.LoadFromSql("LoadPaidContracts", parameters);

                return contracts;
            }
            catch (Exception ex)
            {
                ErrorLog.WriteToFile("", "", ex.StackTrace);
                throw ex;
            }
        }
    }
}
